-
Notifications
You must be signed in to change notification settings - Fork 800
llr::Expression: add support for owned arrays, split out Slice #10382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
So basically there are 3 ways to output list:
btw, where is Vec used? Is it for future use? So IMHO, we should either have But IMHO, this duality with the bool is_model doesn't seem so intuitive. (I think my intuition tell me that an ArrayOutput enum is better than 3 variant of Expression because they are handled the same in many cases.) |
Yes. For my work on repeating Rows, I think I need I have yet to confirm that this is the way to go, but I thought support for returning Vecs might be useful at some point either way. In generated code,
I agree, this would be even more readable.
Ah, interesting idea. I'll try that.
I agree. I always found it surprising.
I'll give it a try. |
b2b775b to
ca42f42
Compare
This PR looks good. But i'm thinking we should wait a bit before merging to be sure this is really needed by the work on the repeated Row. |
Generating Slice::from_slice(&[...]) is only valid for values being passed as function arguments. For a function's return type, for instance, this is invalid, the array will be deallocated immediately. The bool as_model is now an enum, to offer three choices Before: as_model=false => Slice::from_slice as_model=true => ModelRc<VecModel> After: ArrayOutput::Slice => Slice::from_slice ArrayOutput::Vector => Vec ArrayOutput::Model => ModelRc<VecModel>
ca42f42 to
bfc5530
Compare
|
@ogoffart I confirm that this is needed for repeated Row support (which is now working, I'm doing the last bit of polishing). |
Generating Slice::from_slice(&[...]) is only valid for values being passed as function arguments. For a function's return type, for instance, this is invalid, the array will be deallocated immediately. The bool as_model is now an enum, to offer three choices Before: as_model=false => Slice::from_slice as_model=true => ModelRc<VecModel> After: ArrayOutput::Slice => Slice::from_slice ArrayOutput::Vector => Vec ArrayOutput::Model => ModelRc<VecModel>
Generating Slice::from_slice(&[...]) is only valid for values being passed as function arguments. For a function's return type, for instance, this is invalid, the array will be deallocated immediately. The bool as_model is now an enum, to offer three choices Before: as_model=false => Slice::from_slice as_model=true => ModelRc<VecModel> After: ArrayOutput::Slice => Slice::from_slice ArrayOutput::Vector => Vec ArrayOutput::Model => ModelRc<VecModel>
Generating Slice::from_slice(&[...]) is only valid for values being passed as function arguments. For a function's return type, for instance, this is invalid, the array will be deallocated immediately. The bool as_model is now an enum, to offer three choices Before: as_model=false => Slice::from_slice as_model=true => ModelRc<VecModel> After: ArrayOutput::Slice => Slice::from_slice ArrayOutput::Vector => Vec ArrayOutput::Model => ModelRc<VecModel>
Generating Slice::from_slice(&[...]) is only valid for values being passed as function arguments. For a function's return type, for instance, this is invalid, the array will be deallocated immediately. The bool as_model is now an enum, to offer three choices Before: as_model=false => Slice::from_slice as_model=true => ModelRc<VecModel> After: ArrayOutput::Slice => Slice::from_slice ArrayOutput::Vector => Vec ArrayOutput::Model => ModelRc<VecModel>
Generating
Slice::from_slice(&[...])is only valid for values being passed as function arguments. For a function's return type, for instance, this is invalid, the array will be deallocated immediately.My first approach was to add a bool "owned" to Array, but it's getting messy (since there's already a bool "as_model"). So, instead, I split out Slice from the old "Array with as_model=false" case.
Before:
Expression::Array, as_model=false => Slice::from_slice
Expression::Array, as_model=true => ModelRc
After:
Expression::Slice => Slice::from_slice
Expression::Array, as_model=false => Vec
Expression::Array, as_model=true => ModelRc